package com.example.jikejavatrain.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author fangzhuangzhan
 * @date 2021/09/04 11:23
 */
public class LoadBeanToBeanFactory {

    public static void main(String[] args) {

        ApplicationContext ac = new ClassPathXmlApplicationContext("classpath*:applicationcontext*.xml");
        // Component方式
        Student student = ac.getBean(Student.class);
        // Configuration方式
        SchoolConfig school = ac.getBean(SchoolConfig.class);
        // Bean方式
        RedisTest redisTest = ac.getBean(RedisTest.class);
        try {
            System.out.println(student.getName());
            System.out.println(school.getShoolName());
            System.out.println(redisTest.getPort());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


}
